import time
from appium.webdriver import Remote
from appium import webdriver
from selenium.webdriver.common.by import By
from app.swipe import BaesPages

# desired_caps = {
#     'platformName': 'Android',
#     'deviceName': 'emulator-5554',
#     'app': r'C:\test data\__UNI__E090861__20220808095306.apk',
#     'appPackage': 'com.hijyun.property',
#     'appActivity': 'io.dcloud.PandoraEntry',
#     'platformVersion': '7.1.2',
#     'automationName': 'UiAutomator2',
#     'noReset': False,
#     'unicodeKeyboard': True,
#     'resetKeyboard': True,
#     'autoGrantPermissions': True
# }
#
# driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
# driver.find_element(By.ID, "com.hijyun.property:id/btn_custom_privacy_sure").click()
# driver.find_element(By.CLASS_NAME, "android.widget.EditText").send_keys("https.//yunyan-test.frp.xxbu.cn")
# driver.find_element(By.XPATH, "//*[@text = '下一步']")
# driver.quit()

desired_caps = {
    'platformName': 'Android',
    'deviceName': 'emulator-5554',
    'appPackage': 'com.baidu.searchbox',
    'appActivity': 'com.baidu.searchbox.SplashActivity',
    'platformVersion': '7.1.2',
    'automationName': 'UiAutomator2',
    'noReset': False,
    'unicodeKeyboard': True,
    'resetKeyboard': True,
    'autoGrantPermissions': True
}

driver = webdriver.Remote('http://localhost:4723/wd/hub', desired_caps)
driver.implicitly_wait(10)
driver.find_element(By.XPATH, "//*[@text = '同意']").click()
time.sleep(8)
# Android原包的命令，如果使用这个命令，只能用java代码找元素
# 找元素只能用双引号，最外面是单引号
# locator = 'new UiSelector().resourceId("com.baidu.searchbox:id/obfuscated").checkable(false)'
# driver.find_element_by_android_uiautomator(locator).send_keys("1")
baes_page = BaesPages(driver)
baes_page.swipe()
time.sleep(5)
baes_page.swipe(direct='right')
time.sleep(5)



# driver.quit()